﻿using System;
using System.Threading;
using NUnit.Framework;
using Rhino.Mocks;

namespace ThePingMaster.Tests.Unit
{
    [TestFixture]
    public class PingExecuterTests
    {
        private ILogger _logger;
        private IConfiguration _configuration;
        private IPingSender _pingSender;
        private ICommandExecuter _commandExecuter;
        private ManualResetEvent _resetEvent;

        [SetUp]
        public void SetUp()
        {
            _logger = MockRepository.GenerateStub<ILogger>();
            _configuration = MockRepository.GenerateStub<IConfiguration>();
            _pingSender = MockRepository.GenerateStub<IPingSender>();
            _commandExecuter = MockRepository.GenerateStub<ICommandExecuter>();
            _resetEvent = new ManualResetEvent(true);
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Test_Constructor_ThrowsExceptionOnNullLogger()
        {
            // Act
            new PingExecuter(null, _configuration, _pingSender, _commandExecuter, _resetEvent);

            // Assert - see attributes
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Test_Constructor_ThrowsExceptionOnNullConfiguration()
        {
            // Act
            new PingExecuter(_logger, null, _pingSender, _commandExecuter, _resetEvent);

            // Assert - see attributes
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Test_Constructor_ThrowsExceptionOnNullPingSender()
        {
            // Act
            new PingExecuter(_logger, _configuration, null, _commandExecuter, _resetEvent);

            // Assert - see attributes
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Test_Constructor_ThrowsExceptionOnNullPingExecuter()
        {
            // Act
            new PingExecuter(_logger, _configuration, _pingSender, null, _resetEvent);

            // Assert - see attributes
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Test_Constructor_ThrowsExceptionOnNullResetEvent()
        {
            // Act
            new PingExecuter(_logger, _configuration, _pingSender, _commandExecuter, null);

            // Assert - see attributes
        }
    }
}
